﻿using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE80;
using TSVNAddin.VS;

namespace TSVNAddinUtils
{
	public class RemoveBarCommand : UtilsCommandBase
	{
		private readonly DTEInstanceCreator _DTEInstanceCreator;

		public RemoveBarCommand(DTEInstanceCreator dteInstanceCreator)
		{
			_DTEInstanceCreator = dteInstanceCreator;
		}

		protected override void InternalExec(string[] args)
		{
			DTEAdapter dte = null;
			try
			{
				dte = _DTEInstanceCreator.CreateInstance();

				var menuBar = dte.GetMenuBar();
				menuBar.RemoveTortoiseCommandBar();

				var toolBar = dte.GetToolBar();
				toolBar.RemoveTortoiseCommandBar();

				var solutionBar = dte.GetSolutionBar();
				solutionBar.RemoveTortoiseCommandBar();
			}
			finally
			{
				if (dte != null)
					dte.Quit();

				System.Threading.Thread.Sleep(1000);
			}
		}
	}
}
